package com.atguigu.srb.core;

import com.atguigu.srb.common.util.MD5;
import org.joda.time.DateTime;
import org.junit.jupiter.api.Test;
import org.springframework.scheduling.annotation.Scheduled;

import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;

/**
 * @Description:
 * @Author: Gavin
 * @Date: 7/9/2023 12:02 PM
 */
public class Mytest {
    @Test
    void test1(){
        System.out.println(UUID.randomUUID().toString());
        String salt = UUID.randomUUID().toString().replace("-", "").substring(0, 6);
        System.out.println(salt);
    }
    @Test
    void test2() throws UnsupportedEncodingException {
        //url encoder
        String encode = URLEncoder.encode("https://cf.buliang0.cf/clash-rules/nodnsleak.ini", "utf-8");
        System.out.println("encode = " + encode);
    }
    @Test
    void test3(){
        //修改用户的密码2号的
        //349d79
        String encrypt = MD5.encrypt(MD5.encrypt("111111") + "349d79");
        System.out.println("encrypt = " + encrypt);
        String encrypt1 = MD5.encrypt(MD5.encrypt("sundayFantastichaha") + "349d79");
        System.out.println("encrypt1 = " + encrypt1);
    }
    //测试list里面只有一个元素的时候,可不可以使用foreach进行便利
    @Test
    void test4(){
        List<Integer> lists = new ArrayList<>();
        lists.add(3);
        lists.forEach(System.out::println);
    }
    //base64编解码工具的使用
    @Test
    void test5(){
        String str1 = "测试";
        String str2 = "测试a";
        String str3 = "测试ab";
        String str4 = "测试abc";

        byte[] encode1 = Base64.getEncoder().encode(str1.getBytes());
        String s1 = new String(encode1);
        System.out.println("s1 = " + s1);

        byte[] encode2 = Base64.getEncoder().encode(str2.getBytes());
        String s2 = new String(encode2);
        System.out.println("s2 = " + s2);

        byte[] encode3 = Base64.getEncoder().encode(str3.getBytes());
        String s3 = new String(encode3);
        System.out.println("s3 = " + s3);

        byte[] encode4 = Base64.getEncoder().encode(str4.getBytes());
        String s4 = new String(encode4);
        System.out.println("s4 = " + s4);

        /**
         * s1 = 5rWL6K+V
         * s2 = 5rWL6K+VYQ==
         * s3 = 5rWL6K+VYWI=
         * s4 = 5rWL6K+VYWJj
         */
    }
    //rO0ABXNyABFqYXZhLnV0aWwuSGFzaE1hcAUH2sHDFmDRAwACRgAKbG9hZEZhY3RvckkACXRocmVzaG9sZHhwP0AAAAAAAAx3CAAAABAAAAADdAAGYW1vdW50
    // c3IAFGphdmEubWF0aC5CaWdEZWNpbWFsVMcVV/mBKE8DAAJJAAVzY2FsZUwABmludFZhbHQAFkxqYXZhL21hdGgvQmlnSW50ZWdlcjt4cgAQamF2YS5sYW5n
    // Lk51bWJlcoaslR0LlOCLAgAAeHAAAAACc3IAFGphdmEubWF0aC5CaWdJbnRlZ2VyjPyfH6k7+x0DAAZJAAhiaXRDb3VudEkACWJpdExlbmd0aEkAE2ZpcnN0
    // Tm9uemVyb0J5dGVOdW1JAAxsb3dlc3RTZXRCaXRJAAZzaWdudW1bAAltYWduaXR1ZGV0AAJbQnhxAH4ABf///////////////v////4AAAABdXIAAltCrPMX
    // +AYIVOACAAB4cAAAAAInEHh4dAAGbW9iaWxldAALMTg4MTExMTExMTF0AAR0eXBlc3IAEWphdmEubGFuZy5JbnRlZ2VyEuKgpPeBhzgCAAFJAAV2YWx1ZXhx
    // AH4ABQAAAAN4
    @Test
    void test6(){
        /* String message = "rO0ABXNyABFqYXZhLnV0aWwuSGFzaE1hcAUH2sHDFmDRAwACRgAKbG9hZEZhY3RvckkACXRocmVzaG9sZHhwP0AAAAAAAAx3CAAAABAAAAADdAAGYW1vdW50\n" +
                "c3IAFGphdmEubWF0aC5CaWdEZWNpbWFsVMcVV/mBKE8DAAJJAAVzY2FsZUwABmludFZhbHQAFkxqYXZhL21hdGgvQmlnSW50ZWdlcjt4cgAQamF2YS5sYW5n\n" +
                "Lk51bWJlcoaslR0LlOCLAgAAeHAAAAACc3IAFGphdmEubWF0aC5CaWdJbnRlZ2VyjPyfH6k7+x0DAAZJAAhiaXRDb3VudEkACWJpdExlbmd0aEkAE2ZpcnN0\n" +
                "Tm9uemVyb0J5dGVOdW1JAAxsb3dlc3RTZXRCaXRJAAZzaWdudW1bAAltYWduaXR1ZGV0AAJbQnhxAH4ABf///////////////v////4AAAABdXIAAltCrPMX\n" +
                "+AYIVOACAAB4cAAAAAInEHh4dAAGbW9iaWxldAALMTg4MTExMTExMTF0AAR0eXBlc3IAEWphdmEubGFuZy5JbnRlZ2VyEuKgpPeBhzgCAAFJAAV2YWx1ZXhx\n" +
                "AH4ABQAAAAN4"; */
        String message = "5rWL6K+VYWJj";
        byte[] decode = Base64.getDecoder().decode(message.getBytes());
        String string = new String(decode);
        System.out.println("string = " + string);
    }
    @Test
    void test7(){
        String s = new DateTime().plusDays(3).toString("yyyy-MM-dd");
        System.out.println("s = " + s);
    }
    @Test
    void test8() throws ParseException {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        Date date = new Date();
        String format = sdf.format(date);
        System.out.println(format);

        Date parse = sdf.parse("2023-06-23");
        System.out.println("parse = " + parse);

        String s = new DateTime().plusDays(3).toDate().toString();
    }
    //schedule的使用
    @Test
    void Test9(){
        String s = new DateTime().toString("yyyy-MM-dd HH:mm:ss");
        System.out.println("s = " + s);
    }
}

